/**
 * 至少一个属性
 */
export type OneProp<T> = {
  [P in keyof T]-?: Record<P, T[P]>;
}[keyof T];

// 请求响应参数（不包含data）
export interface Result {
  code: string;
  msg: string;
}

// 请求响应参数（包含data）
export interface ResultData<T = any> extends Result {
  [x: string]: any;
  result?: T;
}

// 分页响应参数
export interface ResPage<T> {
  list: T[];
  pageNum: number;
  pageSize: number;
  total: number;
}

// 分页请求参数
export interface ReqPage {
  pageNum: number;
  pageSize: number;
}

// 文件上传模块
export namespace Upload {
  export interface ResFileUrl {
    fileUrl: string;
  }
}

// 登录模块
export namespace Login {
  export interface ReqLoginForm {
    userAccount: string;
    userPasswd: string;
  }
  export type ResLogin = ResultData;
  export interface ModifyPsd {
    oldPasswd: string;
    newPasswd: string;
  }
}

// 用户管理模块
export namespace User {
  export interface ReqUserParams extends ReqPage {
    userAccount: string;
    userName: string;
    startTime: string;
    endTime: string;
    status: number;
  }
  export interface ResUserList<T = any> {
    isDefault: number;
    userAccount: string;
    userName: string;
    startTime: string;
    endTime: string;
    status: number;
    jobNumber: string;
    userType: string;
    sex: string;
    mobile: number;
    userId: string;
    roleList: T[];
    userPasswd?: string;
    company: string;
    department: string;
    email: string;
    headFileId: string;
  }
  export type ResRoleSelList = RoleList;
  interface RoleList {
    roleId: string;
    roleName: string;
    userId?: string;
  }
}
//角色管理模块
export namespace Role {
  export interface ReqRoleParams extends ReqPage {
    roleName: string;
    description: string;
    status: number;
    permissionTree: ResPermission[];
  }
  export interface ResRoleList {
    roleId: string;
    roleName: string;
    description: string;
    users: number;
    status: number;
    createTime: string;
    isDefault: number;
  }
  export interface ResPermission {
    selected?: any;
    permissionId: string;
    permissionName: string;
    permissionType: string;
    children?: ResPermission[];
  }
}
//设备分类管理模块
export namespace DeviceKind {
  export interface ReqDeviceKindParams extends ReqPage {
    kindName: string;
  }
  export interface ResDeviceKindList {
    kindId: number;
    kindName: string;
    deviceNums: number;
    remark: string;
  }
}

//柜体管理模块
export namespace Cabinet {
  export interface ReqCabinetInfoParams extends ReqPage {
    deviceName: string;
    deviceNo: string;
    kindId: number;
  }
  export interface ResCabinetInfoList {
    kindId: number;
    kindName: string;
    deviceId: string;
    deviceName: string;
    deviceNo: string;
    stationNums: number;
    deviceType: string;
    deviceIp: string;
    devicePort: number;
    deviceAddress: number;
    deviceFactory: string;
    remark: string;
    facesNums: number;
    setVoltage: number;
    connectStatus: number;
    address: string;
    teacherId: string;
  }
}

//万能表管理模块
export namespace Meter {
  export interface ReqMeterParams extends ReqPage {
    deviceId: number;
  }
  export interface ResMeterList {
    deviceId: number;
    deviceName: string;
    stationNo: number;
    stationNums: number;
    meterId: number;
    meterName: string;
    rangeStart: string;
    rangeEnd: string;
    readMeasurement: string;
    remark: string;
  }
}

//电压电流源管理模块
export namespace DeviceVc {
  export interface ReqDeviceVcParams extends ReqPage {
    deviceId: number;
  }
  export interface ResDeviceVcList {
    deviceId: number;
    deviceName: string;
    stationNo: number;
    stationNums: number;
    vcId: number;
    vcName: string;
    setVoltage: string;
    setCurrent: string;
    readVoltage: string;
    readCurrent: string;
    outPut: string;
    remark: string;
  }
}

//功率表管理模块
export namespace DevicePower {
  export interface ReqDevicePowerParams extends ReqPage {
    deviceId: number;
  }
  export interface ResDevicePowerList {
    deviceId: number;
    deviceName: string;
    stationNo: number;
    stationNums: number;
    powerId: number;
    powerName: string;
    readMeasurement: string;
    remark: string;
    setVoltage: number;
  }
}

// 数字化教材列表
export namespace Textbook {
  export interface ReqTextbookParams extends ReqPage {
    deviceKindId: number;
    deviceId: number;
    textbookName: string;
  }
  export interface ResTextbookList {
    textbookId: number;
    textbookName: string;
    textbookType: string;
    deviceKindId: number;
    deviceKindName: string;
    deviceId: number;
    deviceName: string;
    startTime: string;
    endTime: string;
    teacherId: number;
    teacherName: string;
    labNums: number;
    linkNums: number;
    createTime: string;
  }
}

//工位管理模块
export namespace Station {
  export interface ReqStationInfoParams extends ReqPage {
    deviceId: string;
    stationName: string;
    stationType: string;
  }
  export interface ResStationInfoList {
    stationId: string;
    deviceId: number;
    deviceName: string;
    stationName: string;
    stationNo: number;
    stationType: string;
    stationAddress: string;
    powerAddress: number;
    createTime: string;
    updateTime: string;
    updateUserName: string;
    deviceFaces?: string;
    baudrate?: string;
  }
}

// 终端管理
export namespace Terminal {
  export interface ReqTerminalInfoParams extends ReqPage {
    deviceId: string;
    termName: string;
    termType: string;
  }
  export interface ResTerminalInfoList {
    stationId: string;
    deviceId: string;
    deviceName: string;
    stationName: string;
    termId: string;
    termName: string;
    termNo: string;
    termType: string;
    termAddress: string;
    linestyle: string;
    protocol: string;
    commType: string;
    termIp: string;
    termPort: string;
    baudrate: string;
    createTime: string;
    updateTime: string;
    connectStatus: number;
    updateUserName: string;
  }
}

//电表管理
export namespace E_Meter {
  export interface ReqE_MeterInfoParams extends ReqPage {
    deviceId: string;
    meterType: string;
    linestyle: string;
    protocol: string;
  }
  export interface ResE_MeterInfoList {
    stationId: string;
    deviceId: string;
    termId: string;
    meterId: string;
    meterNo: string;
    meterType: string;
    meterAddress: string;
    linestyle: string;
    protocol: string;
    baudrate: string;
    ct: string;
    commPort: string;
    messureNo: string;
    createTime: string;
    updateTime: string;
    updateUserName: string;
  }
}
// 控制命令
export namespace CommandTree {
  export interface ReqCommandTreeParams {
    objectStyle: number;
  }
  export interface ResCommandTree {
    dataTree: CommandTreeList[];
  }
  interface CommandTreeList {
    commandId: string;
    dataName: string;
    children?: CommandTreeChild[];
  }
  interface CommandTreeChild extends CommandTreeList {
    CommandTreeList: any[];
  }
}
// 控制表单
export namespace Control {
  export type ReqControlParams<T = DeviceKey> = {
    commandId: string;
    dataItemList?: DeviceItem[];
  } & T &
    OneProp<T>;
  export interface ResControlMap extends DeviceItem {
    dataItemMap: DeviceItem[];
  }
  interface DeviceKey {
    deviceId?: string;
    stationId?: string;
    termId?: string;
    meterId?: string;
    objectId?: string;
  }
  interface DeviceItem {
    itemId: string;
    itemValue: string;
    itemName?: string;
  }
}
// 设备树
export namespace ObjectTree {
  export interface ResObjectTree {
    dataList: ObjectTreeItem[];
  }
  interface ObjectTreeItem {
    deviceId: string;
    deviceName: string;
    stationList: StationItem[];
  }
  interface StationItem {
    stationId: string;
    stationName: string;
    termId: string;
    meterId: string;
  }
}

// 题库管理
export namespace TrainQuestion {
  export interface ReqTrainQuestionParams extends ReqPage {
    objectStyle: string;
  }
  export interface ResTrainQuestionList {
    questionId: number;
    objectStyle: number;
    commandId: string;
    dataName: string;
    createTime: string;
    majorType: number;
    updateTime: string;
    updateUserId: string;
    dataItemList: DataItemList[];
  }
  export interface DataItemList {
    itemId: string;
    itemName: string;
    commandId: string;
  }
}

// 培训计划管理
export namespace TrainPlan {
  export type ReqTrainPlanParams = ReqPage;
  export interface ResTrainPlanList {
    questionId: any;
    dataName: any;
    planId: number;
    planName: string;
    questionNums: string;
    deviceList: DeviceList[];
  }
  export interface DeviceList {
    deviceId: string;
    deviceName: string;
  }

  export interface ReqStationNoParams {
    deviceList: {
      deviceId: string;
    }[];
  }
  export interface ResStationNoList {
    dataList: {
      stationNo: string;
    }[];
  }
  export interface ResSendTrainPlanRecord {
    controlId: number;
    sendStatus: number;
    totalNums: number;
    success: number;
    sendTime: string;
    completeTime: string;
    sendUserName: string;
  }
}

// 试卷管理
export namespace TestPaper {
  export type ReqTestPaperParams = ReqPage;
  export interface ResTestPaperList {
    examId: number;
    examName: string;
    questionNums: number;
    totalScore: number;
    deviceList: DeviceList[];
  }
  export interface ReqStationNoParams {
    deviceList: {
      deviceId: string;
    }[];
  }
  export interface ResStationNoList {
    dataList: {
      stationNo: string;
    }[];
  }
  export interface DeviceList {
    deviceId: string;
    deviceName: string;
  }
}

// 考试管理
export namespace Exam {
  export type ReqExamInfoParams = ReqPage;
  export interface ResExamInfoList {
    testId: number;
    testName: string;
    examId: number;
    examName: string;
    roomName: number;
    startTime: string;
    endTime: string;
    status: number;
    createTime: string;
    connectStatus: number;
    controlList: ControlList[];
  }
  export interface ReqExamSelfParams extends ReqPage {
    testName: string;
  }
  export interface ReqTestSubmitParams {
    controlId: number;
    questionList: {
      eqId: number;
    }[];
    dataList: {
      itemId: number;
      itemValue: string;
    }[];
  }
  export interface ResExamSelfList {
    controlId: number;
    testId: number;
    testName: string;
    roomName: number;
    startTime: string;
    endTime: string;
    status: number;
    totalScore: number;
    winScore: number;
    times: number;
    teacherId: string;
    teacherName: string;
    studentId: string;
    studentName: string;
  }
  export interface ResTestInfo extends ResExamSelfList {
    questionList: QuestionList[];
  }
  interface QuestionList {
    eqId: number;
    objectStyle: number;
    commandId: string;
    dataName: string;
    stationNo: string;
    score: number;
    dataList: DataList[];
    answerIsRight?: number;
  }
  interface ControlList {
    [x: string]: any;
    deviceId: number;
    teacherId: number;
  }
  interface DataList {
    itemId: number;
    itemName: string;
    itemType: number;
    selectList?: {
      lable: string;
      value: string;
    }[];
    isSelected?: boolean;
  }
}

// 论坛
export namespace Forum {
  export interface ReqPostParams extends ReqPage {
    keyword?: string;
  }
  export interface ResPostList {
    postId: number;
    postTitle: string;
    commentNums: number;
    userId: number;
    userName: string;
    userHeadFileId: string;
    createTime: string;
  }

  export interface ReqCommentParams extends ReqPage {
    postId?: string;
  }
  export interface ResCommentList {
    commentId: number;
    commentContent: string;
    floor: number;
    replyNums: number;
    userId: number;
    userName: string;
    userHeadFileId: string;
    createTime: string;
  }
  export interface ResReplyList {
    replyId: number;
    replyContent: string;
    userId: number;
    userName: string;
    userHeadFileId: string;
    createTime: string;
  }
}

//上传
export namespace UploadFile {
  export interface ReqUploadFileParams {
    fileType: string;
    fileContent: string;
    fileName: string;
    fileSuffix: string;
  }
}

// 题库管理
export namespace ExamQuestion {
  export interface ReqExamQuestionParams extends ReqPage {
    questionType: string;
    questionStem: string;
  }
  export interface ResExamQuestionList {
    isRandom: boolean;
    questionId: number;
    questionStem: string;
    questionType: number;
    questionAnswer: any;
    questionScore: number;
    paperNums: number;
    createTime: string;
  }
}

// 试卷管理
export namespace ExamPaper {
  export interface ReqExamPaperParams extends ReqPage {
    paperName: string;
  }
  export interface ResExamPaperList {
    paperId: number;
    paperName: string;
    questionNums: number;
    testNums: number;
    paperScore: number;
    paperNums: number;
    createTime: string;
  }
}

// 试卷管理
export namespace ExamTest {
  export interface ReqExamTestParams extends ReqPage {
    testName: string;
  }
  export interface ResExamTestList {
    testId: number;
    testName: string;
    paperId: number;
    paperName: number;
    roomName: number;
    startTime: string;
    endTime: string;
    teacherId: string;
    teacherName: string;
    status: number;
    questionNums: number;
    paperScore: number;
    studentNums: number;
    createTime: string;
    studentList: string[];
  }
}

// 我的考试
export namespace ExamTestSelf {
  export interface ReqExamTestSelfParams extends ReqPage {
    testName: string;
  }
  export interface ResExamTestSelfList {
    testId: number;
    testName: string;
    paperId: number;
    paperName: number;
    roomName: number;
    startTime: string;
    endTime: string;
    teacherId: string;
    teacherName: string;
    status: number;
    studentNums: number;
    answerTime: string;
    submitTime: string;
    createTime: string;
    score: number;
  }
  export interface ResTestInfo extends ResExamTestSelfList {
    singleSelectionQuestionList: QuestionList[];
    moreSelectionQuestionList: QuestionList[];
    tfQuestionList: QuestionList[];
    completionQuestionList: QuestionList[];
    qaQuestionList: QuestionList[];
    endTime: string;
    startTime: string;
  }
  export interface ReqTestSubmitParams {
    testId: number;
    answerList: {
      questionId: number;
      answerContent: string;
    }[];
  }
  interface QuestionList {
    questionId: number;
    questionStem: string;
    questionScore: number;
    questionAnswer: string;
    answerContent: string;
    answerIsRight?: string;
    optionList?: {
      optionCode: string;
      optionContent: string;
    }[];
  }
}

//功率表管理模块
export namespace DeviceOps {
  export interface ReqDeviceOpsParams extends ReqPage {
    kindId: number;
    deviceName: string;
    deviceNo: string;
  }
  export interface ResDeviceOpsList {
    deviceId: number;
    deviceName: string;
    deviceNo: string;
    deviceType: string;
    address: string;
    teacherName: string;
    teacherId: string;
    remark: string;
    kindId: number;
    stationNums: number;
    deviceIp: string;
    devicePort: number;
    deviceAddress: number;
    deviceFactory: string;
  }

  export interface ReqDeviceLabParams extends ReqPage {
    deviceId: number;
    startCreateTime: string;
    endCreateTime: string;
  }
  export interface ResDeviceLabList {
    logId: number;
    deviceId: number;
    deviceName: string;
    deviceNo: string;
    dataName: string;
    objectName: string;
    reqContent: string;
    rtnContent: string;
    resultFlg: number;
    resultMsg: string;
    userName: string;
    createTime: string;
  }
}

//功率表管理模块
export namespace Banner {
  export interface ReqBannerParams extends ReqPage {
    bannerType: string;
    bannerName: string;
    status: string;
  }
  export interface ResBannerList {
    bannerId: number;
    bannerType: number;
    bannerName: string;
    bannerFileIds: string;
    status: number;
    createTime: string;
  }
}

//实验报告管理模块
export namespace AppData {
  export interface ReqAppDataParams extends ReqPage {
    deviceName: string;
    textbookName: string;
    labName: string;
  }
  export interface ResAppDataList {
    appDataId: string;
    appName: string;
    deviceName: string;
    textbookName: string;
    labName: string;
    labData: string;
    classroom: string;
    uploadDate: string;
    userTime: string;
    userName: string;
    createTime: string;
    appTime: string;
  }
}
